import { IsIn, IsInt, IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { type ICreatePost, POST_STATUS_VALUES } from '@nbase/shared';
import { Type } from 'class-transformer';

/**
 * 创建岗位 DTO
 */
export class CreatePostDto implements ICreatePost {
  @ApiProperty({ description: '岗位编码', example: 'POST_ENGINEER' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(128)
  code!: string;

  @ApiProperty({ description: '岗位名称', example: '软件工程师' })
  @IsString()
  @IsNotEmpty()
  @MaxLength(128)
  name!: string;

  @ApiPropertyOptional({ description: '排序', example: 1 })
  @IsOptional()
  @IsInt()
  sort?: number;

  @ApiPropertyOptional({
    description: '状态（1.启用 2.禁用）',
    example: 1,
    enum: POST_STATUS_VALUES,
  })
  @Type(() => Number)
  @IsInt()
  @IsIn(POST_STATUS_VALUES)
  status!: number;

  @ApiPropertyOptional({ description: '描述', example: '负责软件开发工作' })
  @IsOptional()
  @IsString()
  @MaxLength(256)
  description?: string;
}

